<?php
/**
 * Created by PhpStorm.
 * User: zhangchao
 * Date: 15/8/28
 * Time: 15:43
 */

namespace backend\controllers;


use common\core\ZController;
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;

class EatController extends ZController{

    public function actionIndex()
    {
        $foot_list = [
            '砂锅面',
            '朝天锅',
            '重庆小面',
            'biangbiang面',
            '誉蒸道',
            '觅呀觅呀',
            '和乐王',
            '胸拉面',
            '临沂糁馆',
            '香河肉饼',
            '吃好的',
        ];

        $max_num = count($foot_list);
        $index = rand(0 , $max_num);
        $food_name = isset($foot_list[$index]) ? $foot_list[$index] : '吃好的';
        return $this->render('index' , [
            'food_name' => $food_name
        ]);
    }

    public function actionUpload()
    {
        $bucket = 'home';
        $accessKey = 'bYwAh3aLbcUa6N1JUl8LJbDC5-TL02lDvmO69K1w';
        $secretKey = 'Gj0rvIJpO8yidnRd0rbC2KOKBeYMrFBm2yO4JV09';
        $auth = new Auth($accessKey , $secretKey);
        $token = $auth->uploadToken($bucket);

        return $this->render('upload' , [
            'auth' => $auth,
            'token' => $token,
        ]);
    }
}
